//
//  SEHomeViewController.m
//  TestPrj
//
//  Created by 朱铅峰 on 2019/10/9.
//  Copyright © 2019 Xing. All rights reserved.
//

#import "SEHomeViewController.h"
#import "TableViewContentInsetViewController.h"
#import "CustomScrollViewController.h"
#import "JXPagingViewTestViewController.h"
#import "GKPageScrollViewTestViewController.h"
#import "SlipBackGestureConflictViewController.h"
#import "AlipayPageTabBarViewController.h"
#import "MTShopViewController.h"
#import "XQViewController.h"

@interface SEHomeViewController ()

@property(nonatomic,strong)NSArray *dataSource;

@end

@implementation SEHomeViewController

- (void)loadView {
    
    [super loadView];
    
    UIButton *returnBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    returnBtn.frame = CGRectMake(0, 0, 44, 44);
    returnBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [returnBtn setTitle:@"返回" forState:UIControlStateNormal];
    [returnBtn addTarget:self action:@selector(dismissAction) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:returnBtn];
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    _dataSource = @[@"通过contentInset伪装头部视图",
                    @"UIScrollView内嵌一个UITableView(自测代码，待完善)",
                    @"第三方库JXPagingView测试",
                    @"第三方库GKPageScrollView测试",
                    @"滑动返回手势与ScrollView、UISlider冲突的解决方案",
                    @"模仿支付宝页面",
                    @"模仿饿了么和美团店铺页面",
                    @"模仿星球的星座云"
    ];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"seHomeCell"];
}

- (void)dismissAction {
    
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return _dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"seHomeCell"];
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.numberOfLines = 0;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    NSString *title = _dataSource[indexPath.row];
    cell.textLabel.text = title;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NSInteger index = indexPath.row;
    
    if (index == 0) {
        
        TableViewContentInsetViewController *vc = [[TableViewContentInsetViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    
    } else if (index == 1) {
        
        CustomScrollViewController *vc = [[CustomScrollViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    
    } else if (index == 2) {
        
        JXPagingViewTestViewController *vc = [[JXPagingViewTestViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
        
    } else if (index == 3) {
        
        GKPageScrollViewTestViewController *vc = [[GKPageScrollViewTestViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    
    } else if (index == 4) {
        
        SlipBackGestureConflictViewController *vc = [[SlipBackGestureConflictViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    
    } else if (index == 5) {
        
        AlipayPageTabBarViewController *vc = [[AlipayPageTabBarViewController alloc] init];
        vc.modalPresentationStyle = UIModalPresentationFullScreen;
        [self presentViewController:vc animated:YES completion:nil];
    
    } else if (index == 6) {
        
        MTShopViewController *vc = [[MTShopViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    
    } else if (index == 7) {
        
        XQViewController *vc = [XQViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

@end
